LL_PWR_DeInit APIs migration ¶
The LL initialization and de-initialization functions previously available in the
stm32tnxx_ll_pwr.c
files
within HAL1 are no longer present in HAL2.
In HAL2, all LL C files (
stm32tnxx_ll_pwr.c) have been removed, leaving only the LL header files (
stm32tnxx_ll_pwr.h)
that contain static inline functions.
If users need to initialize or de-initialize pwr using the LL layer, they have two methods:
Utilize STM32CubeMX2 Code Generation: Rely on STM32CubeMX2 to generate code with the LL layer for pwr initialization and de-initialization.
- Replace manually the de-initialization functionReplace the
LL_pwr_DeInitfunction manually with equivalent sequences using the static inline functions provided in the
stm32tnxx_ll_pwr.hfile, tailored to their specific configuration and requirements.
- Replace manually the de-initialization functionReplace the
This approach ensures that the de-initialization sequences are precisely addressing the given use case based on the LL static inline functions provided in the
stm32tnxx_ll_pwr.h
header file.
The sequences offer improved footprint optimization compared to the previous LL initialization functions found in
stm32tnxx_ll_pwr.c.
Related concept: Remove stm32tnxx_ll_ppp.c files
Method 1: Utilize STM32CubeMX2 Code Generation ¶
LL PWR configuration panel ¶
Create a new project with the STM32CubeMX2, then start the initialization and the main configuration.
LL PWR advanced features configuration ¶
Configure the advanced PWR features.
GPIO configuration ¶
Configure GPIO pins.
EXTI configuration ¶
Configure EXTI lines.
Generated PWR initialization and de-initialization sequences ¶
The PWR initialization sequence is generated in the
mx_pwr_init
and the
mx_pwr_deinit
function in the
mx_pwr.c
file under
$YOUR_PROJECT_NAME$/$YOUR_PROJECT_NAME$_SW/generated/STM32Cube_CodeGen.
Related concepts:
|
Topic |
Code Snippet HAL1 |
Code Snippet HAL2 |
|---|---|---|
|
Init and config sequence function |
static void SystemPower_Config(void)
{
/*
* PVD Configuration
*/
LL_PWR_SetPVDLevel(LL_PWR_PVDLEVEL_7);
/*
* Enable the PVD Output
*/
LL_PWR_EnablePVD();
/* Peripheral interrupt init*/
/* PVD_PVM_IRQn interrupt configuration */
NVIC_SetPriority(PVD_PVM_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
NVIC_EnableIRQ(PVD_PVM_IRQn);
}
|
system_status_t mx_pwr_init(void)
{
/****************************************************************************/
/* Configuration of PVD (Programmable Voltage Detector) */
/****************************************************************************/
/* Enable PVD */
LL_PWR_EnablePVD();
/* Configure PVD EXTI Line */
LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_16);
LL_EXTI_DisableFallingTrig_0_31(LL_EXTI_LINE_16);
/* Set line 16 Interrupt priority */
NVIC_SetPriority(PWR_PVD_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0));
NVIC_EnableIRQ(PWR_PVD_IRQn);
return SYSTEM_OK;
}
|
|
Deinit sequence function |
static void SystemPower_DeInit(void)
{
/*
* Disable the PVD Output
*/
LL_PWR_DisablePVD();
/* Peripheral interrupt init*/
NVIC_DisableIRQ(PVD_PVM_IRQn);
}
|
system_status_t mx_pwr_deinit(void)
{
/* Deinit PVD EXTI Line */
LL_EXTI_DisableIT_0_31(LL_EXTI_LINE_16);
LL_EXTI_DisableEvent_0_31(LL_EXTI_LINE_16);
LL_EXTI_DisableRisingTrig_0_31(LL_EXTI_LINE_16);
LL_EXTI_DisableFallingTrig_0_31(LL_EXTI_LINE_16);
LL_EXTI_ClearRisingFlag_0_31(LL_EXTI_LINE_16);
LL_EXTI_ClearFallingFlag_0_31(LL_EXTI_LINE_16);
/* Set line 16 Interrupt priority */
NVIC_DisableIRQ(PWR_PVD_IRQn);
return SYSTEM_OK;
}
|
Method 2: Replace manually the de-initialization functions ¶
LL_PWR_DeInit() API migration ¶
Use
LL_APBn_GRPm_ForceReset()/ReleaseReset()
functions to reset the PWR
Example: The application is using PWR
|
HAL1 |
HAL2 |
|---|---|
LL_PWR_DeInit();
|
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
|